﻿namespace Z2
{

	#region Using

	using System;
	using System.IO;
using Microsoft.Xna.Framework;

	#endregion

	static class Program
	{
		private static Game _game;
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		static void Main(string[] args)
		{
			AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Program.UnhandledException);
			string runMap = string.Empty;
			if (args != null && args.Length > 0)
			{
				runMap = args[0];
			}
			using (_game = new Zelvici2(runMap))
			{
				_game.Run();
			}
		}

		private static void UnhandledException(object sender, UnhandledExceptionEventArgs e)
		{
			try
			{
				string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Error.txt");
				using (TextWriter writer = (TextWriter)File.CreateText(path))
				{
					writer.Write(e.ExceptionObject);
				}
			}
			finally
			{
				if (_game.IsActive)
				{
					_game.Exit();
				}
			}
		}

	}
}

